﻿using System;
using System.Collections.Generic;
using Jin.Core.Schema;
using System.Data;

namespace Jin.Core.DataProviders
{
    /// <summary>
    /// 模式生成
    /// </summary>
    public interface ISchemaGenerator
    {
        /// <summary>
        /// 创建表
        /// </summary>
        /// <param name="tbl"></param>
        /// <returns></returns>
        string BuildCreateTableStatement(ITable tbl);

        /// <summary>
        /// 删除表
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        string BuildDropTableStatement(string tableName);
        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="column">列</param>
        /// <returns></returns>
        string BuildAddColumnStatement(string tableName, IColumn column);
        /// <summary>
        /// 跟新列
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        string BuildAlterColumnStatement(IColumn column);
        /// <summary>
        /// 移除列
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="columnName">列名</param>
        /// <returns></returns>
        string BuildDorpColumnStatement(string tableName, string columnName);

        /// <summary>
        /// 获取本地类型
        /// </summary>
        /// <param name="dbType">数据库类型</param>
        /// <returns></returns>
        string GetNativeType(DbType dbType);

        /// <summary>
        /// 生成的列
        /// </summary>
        /// <param name="table">表包含的列</param>
        /// <returns>SQL片段代表提供的列</returns>
        string GenerateColumns(ITable table);
        /// <summary>
        /// 设置列属性
        /// </summary>
        /// <param name="column">列</param>
        /// <returns></returns>
        string GenerateColumnAttributes(IColumn column);

        /// <summary>
        /// 获取表
        /// </summary>
        /// <param name="provider">驱动程序</param>
        /// <param name="table">表名</param>
        /// <returns></returns>
        ITable GetTableFromDB(IDataProvider provider,string tableName);
        /// <summary>
        /// 获取表集合
        /// </summary>
        /// <param name="provider">数据库驱动程序</param>
        /// <returns></returns>
        string[] GetTableList(IDataProvider provider);

        /// <summary>
        /// 获取类型
        /// </summary>
        /// <param name="sqlType"></param>
        /// <returns></returns>
        DbType GetDbType(string sqlType);
        /// <summary>
        /// 客户端名
        /// </summary>
        string ClientName { get; set; }
    }
}
